package com.zhia.demo.config;

import com.zhia.demo.constont.RootPath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

/**
 * @author DONG
 * @create 2023/10/26 13:02
 */
@Configuration
public class UploadConfig implements WebMvcConfigurer {
    /**
     * 静态资源处理
     **/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //addResourceLocations:存放静态资源的路径
        //addResourceHandler:映射后的访问路径
        registry.addResourceHandler("/res/**").addResourceLocations("file:" + RootPath.ROOT_PATH);
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
